//
//  XMGViewController.m
//  百思不得姐
//
//  Created by 杨庆 on 2016/12/30.
//  Copyright © 2016年 杨庆. All rights reserved.
//

#import "XMGViewController.h"
#import "XMGEssenceViewController.h"
#import "XMGNewViewController.h"
#import "XMGFriendTrendsViewController.h"
#import "XMGMeViewController.h"
#import "XMGTabBar.h"
#import "XMGNavgationController.h"
@interface XMGViewController ()

@end

@implementation XMGViewController

+(void)initialize{
	
	//字体&颜色-->appearance 统一设置
	NSMutableDictionary*normalDict=[NSMutableDictionary dictionary];
	normalDict[NSFontAttributeName]=[UIFont systemFontOfSize:12];
	normalDict[NSForegroundColorAttributeName]=[UIColor grayColor];
	
	NSMutableDictionary*selectDict=[NSMutableDictionary dictionary];
	selectDict[NSForegroundColorAttributeName]=[UIColor darkGrayColor];
	
	UITabBarItem*item=[UITabBarItem appearance];
	[item setTitleTextAttributes:normalDict  forState:UIControlStateNormal];
	[item setTitleTextAttributes:selectDict forState:UIControlStateSelected];
	
}

- (void)viewDidLoad {
    [super viewDidLoad];
	
	//tabBar添加子控制器1
	[self setupController:[[XMGEssenceViewController alloc]init] title:@"精华" image:@"tabBar_essence_icon" selectImage:@"tabBar_essence_click_icon"];
	
	//tabBar添加子控制器2
	[self setupController:[[XMGNewViewController alloc]init] title:@"新帖" image:@"tabBar_new_icon" selectImage:@"tabBar_new_click_icon"];
	
		//tabBar添加子控制器3
	[self setupController:[[XMGFriendTrendsViewController alloc]init] title:@"关注" image:@"tabBar_friendTrends_icon" selectImage:@"tabBar_friendTrends_click_icon"];
	
		//tabBar添加子控制器4
	[self setupController:[[XMGMeViewController alloc]init] title:@"我" image:@"tabBar_me_icon" selectImage:@"tabBar_me_click_icon"];
	
	//自定义 tabBar
	[self setValue:[[XMGTabBar alloc]init] forKey:@"tabBar"];
	
}

-(void)setupController:(UIViewController*)vc title:(NSString*)title image:(NSString*)image selectImage:(NSString*)selectImage{
	
	vc.navigationItem.title=title;
	vc.tabBarItem.title=title;
	vc.tabBarItem.image=[UIImage imageNamed:image];
	vc.tabBarItem.selectedImage=[UIImage imageNamed:selectImage];
	
	//包装导航控制器-->形成1对1对多 ==>  1个 tabBarItem 对应一个功能栏,一个功能栏对应多个内容界面
	XMGNavgationController*nav=[[XMGNavgationController alloc]initWithRootViewController:vc];
	[self addChildViewController:nav];

}



@end
